package model

import (
	"gorm.io/gorm"
	"smart-health-platforms/config"
	"time"
)

type Opinion struct {
	Id        uint           `gorm:"column:id;type:bigint UNSIGNED;primaryKey;not null;" json:"id"`
	UsersId   uint           `gorm:"column:users_id;type:bigint UNSIGNED;comment:发表人;not null;default:0;" json:"users_id"`                     // 发表人
	Opinion   string         `gorm:"column:opinion;type:varchar(255);comment:意见;not null;" json:"opinion"`                                     // 意见
	CreatedAt time.Time      `gorm:"column:created_at;type:datetime(3);comment:创建时间;not null;default:CURRENT_TIMESTAMP(3);" json:"created_at"` // 创建时间
	UpdatedAt time.Time      `gorm:"column:updated_at;type:datetime(3);comment:修改时间;not null;default:CURRENT_TIMESTAMP(3);" json:"updated_at"` // 修改时间
	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);comment:删除时间;default:NULL;" json:"deleted_at"`                          // 删除时间
}

func (o *Opinion) TableName() string {
	return "opinion"
}

// 用户发表意见
func (o *Opinion) ExpressOpinions() error {
	return config.DB.Create(&o).Error
}
